package com.cq.hd.admin.controller;

import com.cq.hd.admin.annotation.RequiresPermissionsDesc;
import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.member.api.TbMemberFeeConfigApi;
import com.cq.hd.member.api.dto.MemberFeeConfigPageDto;
import com.cq.hd.member.api.dto.MemberFeeConfigSaveDto;
import com.cq.hd.member.api.dto.MemberFeeConfigUpdateDto;
import com.cq.hd.member.api.vo.MemberFeeConfigPageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(tags = "会员套餐配置相关接口")
@Slf4j
@RestController
@RequestMapping("/memberFeeConfig")
public class TbMemberFeeConfigController extends BaseController{

    @Autowired
    private TbMemberFeeConfigApi memberFeeConfigApi;

    @ApiOperation(value = "保存会员套餐配置")
    @ApiImplicitParam(name = "memberFeeConfigSaveDto", value = "保存参数", required = true, paramType = "body", dataType = "MemberFeeConfigSaveDto")
    @RequiresPermissions("business:memberFeeConfig:save")
    @RequiresPermissionsDesc(menu = {"商家管理", "会员套餐配置"}, button = "保存")
    @PostMapping("/save")
    public Result<Long> saveMemberFeeConfig(@Validated @RequestBody MemberFeeConfigSaveDto memberFeeConfigSaveDto) {
        return memberFeeConfigApi.saveMemberFeeConfig(memberFeeConfigSaveDto);
    }

    @ApiOperation(value = "更新会员套餐配置")
    @ApiImplicitParam(name = "memberFeeConfigUpdateDto", value = "更新参数", required = true, paramType = "body", dataType = "MemberFeeConfigUpdateDto")
    @RequiresPermissions("business:memberFeeConfig:update")
    @RequiresPermissionsDesc(menu = {"商家管理", "会员套餐配置"}, button = "更新")
    @PostMapping("/update")
    public Result<Boolean> updateMemberFeeConfig(@Validated @RequestBody MemberFeeConfigUpdateDto memberFeeConfigUpdateDto) {
        return memberFeeConfigApi.updateMemberFeeConfig(memberFeeConfigUpdateDto);
    }

    @ApiOperation(value = "会员套餐配置列表")
    @ApiResponse(response = MemberFeeConfigPageVo.class, code = 200, message = "接口返回对象参数")
    @RequiresPermissions("business:memberFeeConfig:list")
    @RequiresPermissionsDesc(menu = {"商家管理", "会员套餐配置"}, button = "查询")
    @GetMapping("/page")
    public Result<Page<MemberFeeConfigPageVo>> pageMemberFeeConfig(MemberFeeConfigPageDto memberFeeConfigPageDto) {
        return memberFeeConfigApi.pageMemberFeeConfig(memberFeeConfigPageDto);
    }
}
